<template>
    <div>
        <el-form :model="formData" :rules="rules">
            <el-table :data="formData.tableData">
                <el-table-column label="第一列">
                    <el-form-item slot-scope="scope" :prop="'tableData.' + scope.$index + '.l1'" :rules="rules.rule1">
                        <el-input v-model="formData.tableData[scope.$index].l1"></el-input>
                    </el-form-item>
                </el-table-column>
                <el-table-column label="第二列">
                    <el-form-item slot-scope="scope" :prop="'tableData.' + scope.$index + '.l1'" :rules="rules.rule1">
                        <div >{{formData.tableData[scope.$index].l2}}</div>
                    </el-form-item>
                </el-table-column>
            </el-table>
        </el-form>
    </div>
</template>

<script>
    export default {
        name: "validator",
        data() {
            return {

                formData: {
                    tableData: [{l1: '1', l2: '21'}, {l1: '2', l2: '22'}, {l1: '3', l2: '23'},],
                },
                rules: {
                    rule1: [{
                        validator: this.test1,
                        trigger: 'blur'
                    }]
                }
            }
        },
        methods: {
            test1(rule, value, callback) {
                console.log(rule)
                console.log(value)
                console.log(callback)
                if (parseInt(value) < parseInt(this.formData.tableData[2].l1))
                    callback(new Error('不够大'));
                if (value === '') {
                    callback(new Error('请再次输入密码'));
                }
            }
        }
    }
</script>

<style scoped>

</style>